<template>
	<view class="footer-bar">
		<!-- 审核按钮 -->
		<view class="footer">
			<view class="inner">
				<!-- <u-col span="4" class="prices">
					<text class="txt">总价：</text>
					<text class="price">
						<text class="uni">¥</text>
						<text class="num">{{ data.finalSalesPriceTax }}</text>
					</text>
				</u-col> -->
				<view span="8" class="btn">
					<u-button type="primary" v-if="auth.update" @click="toPath">编辑</u-button>
					<u-button type="primary" v-if="data.isCheck == 1" @click="popOpen(1)">通过</u-button>
					<u-button type="error" v-if="data.isCheck == 1" @click="popOpen(2)">拒绝</u-button>
					<u-button type="warning" v-if="data.isRecheck == 1" @click="popOpen(4)">撤回审核</u-button>
				</view>
			</view>
		</view>

		<!-- 弹窗 -->
		<u-popup mode="bottom" height="300px" :closeable="true" v-model="popStatus" border-radius="10">
			<view class="pop-title">审核意见</view>
			<view class="form-item">
				<u-input v-model="remarks" :height="180" type="textarea" maxlength="200" :border="true" placeholder="请填写审核意见"></u-input>
			</view>
			<view class="pop-btn">
				<u-button type="primary" @click="examineVerify">提交</u-button>
			</view>
		</u-popup>
	</view>
</template>

<script>
export default {
	name: 'footerBar',
	props: {
		data: {
			type: Object,
			default: () => {},
		},
		auth: {
			type: Object,
			default: () => {},
		},
		id: {
			type: [String, Number],
			default() {
				return 0;
			},
		},
	},
	data() {
		return {
			// 弹窗状态
			popStatus: false,
			// 审核状态
			status: 0,
			// 备注
			remarks: '',
		};
	},
	mounted() {},
	methods: {
		// 跳转
		toPath() {
			uni.navigateTo({
				url: '/pages/customerManagement/quotationAdd/quotationAdd?id=' + this.id,
			});
		},
		// 打开审核弹窗
		popOpen(status) {
			this.status = status;
			this.popStatus = true;
		},
		// 审核
		async examineVerify() {
			if (!this.remarks.trim()) {
				uni.showToast({
					icon: 'none',
					title: '请输入审核意见',
				});
				return;
			}
			let data = {
				id: this.data.quotationId,
				recordId: this.data.examineRecordId,
				status: this.status,
				batchId: this.data.batchId,
				remarks: this.remarks,
			};
			let res = await this.$api.customer.quotation.examineVerify(data);
			if (res.code === 200) {
				this.popStatus = false;
				this.remarks = '';
				this.$emit('onverify');
			}
		},
	},
};
</script>

<style lang="scss" scoped>
.footer {
	height: 70px;

	.inner {
		position: fixed;
		left: 0;
		right: 0;
		bottom: 0;
		z-index: 10;

		.btn {
			display: flex;
			padding: 10px;
			.u-btn {
				flex: 1;
				margin: 0;
				border-radius: 30px;
				padding: 0 12px;
				border: 0;
				margin: 10px;
				&:after {
					border-radius: 30px;
				}
			}
		}
	}
}

.pop-title {
	height: 40px;
	line-height: 40px;
	font-size: 18px;
	text-align: center;
}
.form-item,
.pop-btn {
	padding: 0 15px;
}
.pop-btn {
	margin-top: 15px;
}
</style>